class Student:
  def __init__(self, name, age, grade):
    self.name = name
    self.age = age
    self.grade = grade

  def __str__(self):
    # 需要return一个返回值，否则报错
    # __str__ returned non-string (type NoneType)
    str = "我是一名学生，我叫%s，年龄是%d岁，年级是%s年级。" % (self.name, self.age, self.grade)
    return str

sunny = Student("sunny", 8, 3)
print(sunny)

heby = Student("heby", 10, 5)
print(heby)

class Person:
  def __init__(self, name, age, workplace):
    self.name = name
    self.age = age
    self.workplace = workplace
  
  def work(self):
    print("%s在工作。" % (self.name))

class Teacher(Person):
  def work(self):
    print("%s在%s教书。" % (self.name, self.workplace))

class Doctor(Person):
  def work(self):
    print("%s在%s治病。" % (self.name, self.workplace))

Bobo = Teacher("Bobo", 30, "小学")
Bobo.work()

Make = Doctor("Make", 32, "人民医院")
Make.work()